<?php

/**
 * Framework_Module_Profile
 *
 * @author      Ian Szewczyk <roamzero@gmail.com>
 * @copyright   (c) 2007 Ian Szewczyk. All rights reserved.
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @package Modules
 * @filesource
 */

/**
 * Framework_Module_Profile
 *
 * @author Ian Szewczyk <roamzero@gmail.com>
 * @package Modules
 */
class Framework_Module_Profile extends Framework_Module
{
	 
	/**
	 * __construct
	 *
	 * Initializes the module: sets the default presenter, the allowed
	 * conrollers, and the allowed events
	 *
	 * @access 		public
	 * @return 		void
	 */
	public function __construct()
	{
		parent::__construct();
		if (Framework::$request->isAjax()) {
			$this->presenter = 'Module';
		} else {
			$this->presenter = 'Smarty';
		}
		// Set outer template
		$this->pageTemplateFile = 'ProfilePage.tpl';
		// Set inner template
		$this->tplFile = 'Profile.tpl';
		// Set the controller
		$this->controllers[] = 'Peopletab';
			
		//Caching
		$this->isCacheable = true;
		$this->cacheHandlerClass = 'Module';
			
			
	}

	/**
	 * __default
	 *
	 * Gets owners profile information
	 *
	 * @access 		public
	 * @return 		mixed 		boolean true on success, PEAR_Error on failure
	 */
	public function __default()
	{


		$cacheHandler = $this->getCacheHandler();

		$owner = Framework_Owner::singleton($cacheHandler);
		 
		// Set basic details
		$this->setData('basicDetails', $owner->getBasicData());

		$contactInfo = $owner->getProfileInfo($this->user, 'contact', $cacheHandler);
		$this->setData('profileContact', $contactInfo);

		$personalInfo = $owner->getProfileInfo($this->user, 'personal', $cacheHandler);
		$this->setData('profilePersonal', $personalInfo);

		$interestsInfo = $owner->getProfileInfo($this->user, 'interests', $cacheHandler);
		$this->setData('profileInterests', $interestsInfo);

	}
}

?>